<template>
    <div id="TextDbAlertList" ref="TextDbAlertList" class="TextDbAlertList">
        <div class="textLable">
            <span style="color: rgb(229, 230, 250)"> 数据库告警信息： </span>
            <span style="color: rgb(255, 222, 51)">
            <p>
                告警信息: <span style="color: rgb(229, 230, 250)">{{showData.alertInfo}} </span>
            </p>
            <p>
                数据库名称: <span style="color: rgb(229, 230, 250)">{{showData.dbSid}} </span>
            </p>
            <p>
                告警类型: <span style="color: rgb(229, 230, 250)">{{showData.infoType}} </span>
            </p>
            <p>
                告警对象: <span style="color: rgb(229, 230, 250)">{{showData.monObject}} </span>
            </p>
            <p>
                记录时间: <span style="color: rgb(229, 230, 250)">{{showData.recordTime}} </span>
            </p>
            <p>
                系统名称: <span style="color: rgb(229, 230, 250)">{{showData.systemName}} </span>
            </p>
        </span>
        </div>
    </div>
</template>>

<script>
import { fetchData } from '@/api/index.js';
import bus from 'common/bus.js';

export default {
    data() {
        return {
            postData: {
                opera: 'dbalertlist',
                curPage: 1,         
                pageSize: 20,
                sort: {
                    sortColumn: '',
                    sortOrders: ''
                },
                filtersType: 'fuzzyquery',
                filters: {
                    "monid": "02F2CD5CE4544B74943C90D3102D928B",
                },
            },
            showData: {
                alertInfo: '',
                dbSid: '',
                infoType: '',
                monObject: '',
                recordTime: '',
                systemName: '',
            },
            TextDbAlertList: {},
            timerName: 'TextDbAlertList',
            timerEventName: 'timerTextDbAlertList',
            timerInterval: 1000 * 60
        }
    },
    created() {
        this.getData();
        bus.$emit('timerNewTodo', {
            name: this.timerName,
            eventName: this.timerEventName,
            interval: this.timerInterval,
            intervalNow: 0
        });

        bus.$on(this.timerEventName, msg => {
            if (msg.isGetData) {
                this.getData();
            }
        });
    },
    mounted() {
        
    },
    computed: {
        postDataFn() {
            return {
                postData : JSON.stringify(this.postData)
            }
        }
    },
    methods: {
        getData(){
            fetchData(
                this.postDataFn
            ).then((res) => {
                this.showData.alertInfo = res.data[0].ALERTINFO;
                this.showData.dbSid = res.data[0].DB_SID;
                this.showData.infoType = res.data[0].INFOTYPE;
                this.showData.monObject = res.data[0].MON_OBJECT;
                this.showData.recordTime = res.data[0].RECORD_TIME;
                this.showData.systemName = res.data[0].SYSTEMNAME;
            });
        }
    },
    beforeDestroy() {
        bus.$emit('timerNewTodo', {
            name: this.timerName
        });
    },
    watch:{
        
    }
}
</script>

<style scoped>
.TextDbAlertList{
    /* height: 60px; */

}
.textLable{
    padding: 10px;
}
</style>